package com.github.permissiondog.cancanpandroid.ui.view;

import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;

import android.os.Bundle;

import com.github.permissiondog.cancanpandroid.R;
import com.github.permissiondog.cancanpandroid.databinding.ActivityApplicantMainBinding;
import com.github.permissiondog.cancanpandroid.databinding.ActivityApproverMainBinding;

public class ApproverMainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ActivityApproverMainBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_approver_main);
        binding.bnvApproverMain.setOnItemSelectedListener(item -> {
            var fragment = switch (item.getItemId()) {
                case R.id.approve_fragment -> ApproveFragment.newInstance();
                case R.id.settings_fragment -> new SettingsFragment();
                default -> throw new IllegalStateException("Unexpected value: " + item.getItemId());
            };

            getSupportFragmentManager().beginTransaction().replace(R.id.fl_approver_main, fragment).commit();
            return true;
        });
        binding.bnvApproverMain.setSelectedItemId(R.id.approve_fragment);
    }
}